package com.ltkj.baseplatform.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.baseplatform.domain.SerTravelType;
import com.ltkj.baseplatform.service.ISerTravelTypeService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;

/**
 * 游记分类Controller
 * 
 * @author chenzeen
 * @date 2023-09-02
 */
@Api(tags = "游记分类")
@RestController
@RequestMapping("/travel")
public class SerTravelTypeController extends BaseController
{
    @Autowired
    private ISerTravelTypeService serTravelTypeService;

    /**
     * 查询游记分类列表
     */
    @ApiOperation("查询游记分类列表")
    @RequiresPermissions("baseplatform:travel:list")
    @GetMapping("/list")
    public AjaxResult list(SerTravelType serTravelType)
    {
        List<SerTravelType> list = serTravelTypeService.selectSerTravelTypeList(serTravelType);
        return success(list);
    }

    /**
     * 导出游记分类列表
     */
    @ApiOperation("导出游记分类列表")
    @RequiresPermissions("baseplatform:travel:export")
    @Log(title = "游记分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SerTravelType serTravelType)
    {
        List<SerTravelType> list = serTravelTypeService.selectSerTravelTypeList(serTravelType);
        ExcelUtil<SerTravelType> util = new ExcelUtil<SerTravelType>(SerTravelType.class);
        util.exportExcel(response, list, "游记分类数据");
    }

    /**
     * 获取游记分类详细信息
     */
    @ApiOperation("获取游记分类详细信息")
    @RequiresPermissions("baseplatform:travel:query")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(serTravelTypeService.selectSerTravelTypeByTypeId(typeId));
    }

    /**
     * 新增游记分类
     */
    @ApiOperation("新增游记分类")
    @RequiresPermissions("baseplatform:travel:add")
    @Log(title = "游记分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SerTravelType serTravelType)
    {
        return toAjax(serTravelTypeService.insertSerTravelType(serTravelType));
    }

    /**
     * 修改游记分类
     */
    @ApiOperation("修改游记分类")
    @RequiresPermissions("baseplatform:travel:edit")
    @Log(title = "游记分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SerTravelType serTravelType)
    {
        return toAjax(serTravelTypeService.updateSerTravelType(serTravelType));
    }

    /**
     * 删除游记分类
     */
    @ApiOperation("删除游记分类")
    @RequiresPermissions("baseplatform:travel:remove")
    @Log(title = "游记分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(serTravelTypeService.deleteSerTravelTypeByTypeIds(typeIds));
    }
}
